package cn.xhz.gdal.util;

import cn.hutool.core.util.ObjectUtil;
import cn.xhz.gdal.exception.GDALException;

import java.util.Objects;

/**
 * 断言对象
 *
 * @author life-oss
 * @since 2022/12/13
 */
public class Assert {

    /**
     * 判断是否为空
     */
    public static void isNotNull(Object object,String errorMsg){
        if (ObjectUtil.isEmpty(object)){
            throw  new NullPointerException(errorMsg);
        }
    }

    /**
     * 当检查一个时其实已经报错了
     * @param errorMsg
     * @param object
     */
    public static void isAnyNotNull(String errorMsg,Object... object){
        for (Object o : object) {
            if (o==null){
                throw  new GDALException(errorMsg);
            }
        }
    }
    public static void isNotNull(Object object,String errorMsg,Class<RuntimeException> runtimeException){
        if (object==null){
            throw new RuntimeException(errorMsg);
        }
    }
}
